//
// Problem 1: gas stations
//
// Created by tianq on 24-12-4.
//

#include <iostream>
#include <vector>
#include <limits>
#include <unordered_map>
using namespace std;

int main() {
    int n, k;  // n: fuel tank size, k: gas stations count
    vector<int> distances;

    cin >> n >> k;
    for (int i = 0; i < k; i++) {
        int tmp = 0;
        cin >> tmp;
        distances.emplace_back(tmp);
    }

    int minRefill = 0; // 0: in case there is no stations between
    unordered_map<int, int> map; // <GasRemain,RefillCount>
    map.emplace(n, 0);

    for (const int &ahead: distances) {
        unordered_map<int, int> newMap; // <GasRemain,RefillCount>
        minRefill = numeric_limits<int>::max();
        for (const auto &[remain, refill]: map) {
            if (remain < ahead) continue; // we can't reach next station
            if (refill < minRefill) minRefill = refill;

            if (int curRemain = remain - ahead;
                !newMap.contains(curRemain) || refill < newMap[curRemain]) {
                newMap[curRemain] = refill;
            }
            if (!newMap.contains(n) || refill + 1 < newMap[n])
                newMap[n] = refill + 1;
        }
        map = newMap;
    }

    cout << minRefill << endl;
    return 0;
}
